BG = {};

local this = BG;
local bg1;
local bg2;
function BG.New()
    resMgr:LoadPrefab("thunder",{'BG'},this.OnLoadPrefab)
end

function BG.OnLoadPrefab(prefabs)
    bg1 = newObject(prefabs[0]);
    bg1.transform.position = Vector3.zero;

    bg2 = newObject(prefabs[0]);
    bg1.transform.position = Vector3(0, 10, 0);

    UpdateBeat:Add(this.Update);
end

function BG.Update()
    bg1.transform:Translate(Vector3.down * 1 * Time.deltaTime);
    bg2.transform:Translate(Vector3.down * 1 * Time.deltaTime);
    if (bg1.transform.position.y < -10) then
    
        bg1.transform.position = Vector3(0, 10, 0);
    end

    if (bg2.transform.position.y < -10) then
    
        bg2.transform.position = Vector3(0, 10 ,0);
    end
end